package com.sky.mapper;

import com.sky.annotations.AutoFill;
import com.sky.entity.EmployeeEntity;
import com.sky.enumeration.OperationType;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface EmployeeMapper {

    @Select("select * from employee")
    EmployeeEntity select();

    @Select("select * from employee where username = #{username}")
    EmployeeEntity getByUserName(@Param("username") String username);

    @Insert("insert into employee (id,name,username,password,phone,sex,id_number,status,create_time,update_time,create_user,update_user) values (" +
            "null,#{name},#{username},#{password},#{phone},#{sex},#{idNumber},#{status},#{createTime},#{updateTime},#{createUser},#{updateUser})")
    @AutoFill(OperationType.INSERT)
    Integer save(EmployeeEntity employee);

    List<EmployeeEntity> getByName(String name);

    @AutoFill(OperationType.UPDATE)
    void update(EmployeeEntity employeeEntity);

    @Select("select * from employee where id = #{id}")
    EmployeeEntity getById(Long id);
}
